package com.xzy.sms.web.system.service.security;

import java.io.Serializable;

/**
 * 登录用户信息
 * 
 * @author macong
 * @since 1.0
 * @version 2014-10-15 macong
 */
public class UserProfile implements Serializable {
    
    /** 序列号 */
    private static final long serialVersionUID = 1L;
    
    /**
     * 用户ID,内部唯一标识
     */
    private String userId;
    
    /**
     * account
     */
    private String account;
    
    /**
     * 用户name
     */
    private String userName;
    
    /**
     * 用户类型
     */
    private String type;
    
    /**
     * 构造函数
     */
    public UserProfile() {
    }
    
    /**
     * 构造函数
     * 
     * @param userId openId
     * @param account account
     * @param userName name
     */
    public UserProfile(String userId, String account, String userName) {
        this(userId, account, userName, null);
    }
    
    /**
     * 构造函数
     * 
     * @param userId userId
     * @param account account
     * @param userName name
     * @param type type
     */
    public UserProfile(String userId, String account, String userName, String type) {
        super();
        this.userId = userId;
        this.account = account;
        this.userName = userName;
        this.type = type;
    }
    
    /**
     * 本函数输出将作为默认的<shiro:principal/>输出，且作为权限缓存的key.
     */
    @Override
    public String toString() {
        return userId + "_" + account;
    }
    
    /**
     * @return xx
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((userId == null) ? 0 : userId.hashCode());
        return result;
    }
    
    /**
     * @param obj xx
     * @return xx
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        UserProfile other = (UserProfile) obj;
        if (userId == null) {
            if (other.userId != null)
                return false;
        } else if (!userId.equals(other.userId))
            return false;
        return true;
    }
    
    /**
     * @return userId
     */
    public String getUserId() {
        return userId;
    }
    
    /**
     * @param userId 要设置的 userId
     */
    public void setUserId(String userId) {
        this.userId = userId;
    }
    
    /**
     * @return account
     */
    public String getAccount() {
        return account;
    }
    
    /**
     * @param account 要设置的 account
     */
    public void setAccount(String account) {
        this.account = account;
    }
    
    /**
     * @return type
     */
    public String getType() {
        return type;
    }
    
    /**
     * @param type 要设置的 type
     */
    public void setType(String type) {
        this.type = type;
    }
    
    /**
     * @return the userName
     */
    public String getUserName() {
        return userName;
    }
    
    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }
    
}
